import 'package:flutter/material.dart';
import 'package:treadmill/pages/run_page.dart';
import 'package:treadmill/pages/scene_page.dart';

import 'mine_page.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage>
    with TickerProviderStateMixin<HomePage> {
  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController = new TabController(length: 3, vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: TabBarView(
          controller: _tabController,
          children: <Widget>[RunPage(), ScenePage(), MinePage()]),
      bottomNavigationBar: Container(
        height: 60,
        child: Material(
          elevation: 10.0,
          child: TabBar(
            controller: _tabController,
            unselectedLabelColor: Colors.grey,
            indicatorColor: Colors.transparent,
            indicatorSize: TabBarIndicatorSize.tab,
            labelPadding: EdgeInsets.all(3),
            labelColor: Colors.blue,
            tabs: <Widget>[
              Tab(
                child: Column(
                  children: <Widget>[
                    Icon(
                      Icons.directions_walk,
                    ),
                    Text(
                      '跑步',
                    )
                  ],
                ),
              ),
              Tab(
                child: Column(
                  children: <Widget>[
                    Icon(
                      Icons.landscape,
                    ),
                    Text(
                      '场景',
                    )
                  ],
                ),
              ),
              Tab(
                  child: Column(
                    children: <Widget>[
                      Icon(
                        Icons.person,
                      ),
                      Text(
                        '我的',
                      )
                    ],
                  ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
